package com.tang.algorithm.recursion;

/**
 * @author tlm
 * @Description 各位相加
 * @date 2020/7/23 7:06 下午
 */
public class LeetCode258 {
	public static void main(String[] args) {
		LeetCode258 leetCode258 = new LeetCode258();
		System.out.println(leetCode258.addDigits(44));
	}

	public int addDigits(int num) {
		if (num <= 9) {
			return num;
		}
		int res = 0;
		while (num > 0) {
			res += num % 10;
			num = num / 10;
		}
		return addDigits(res);
	}
}
